import { useTokens } from "@/stores/tokens";
import { ref } from "vue";

const token = useTokens();

const commFun = {
    /**用来更具索引取对于的cols宽度 */
    getIdx: function (type: TabType, idx: number) {
        const arrs = [
            [1, 10],
            [1, 10],
            [1, 4, 4, 2.5],
            [1, 4, 4, 2.5]
        ];
        return arrs[type][idx];
    },
    /**用来计算当item是第几行 */
    getItemidx: function (item: number, idx: number, sum: number) {
        return (idx - 1) * sum + item;
    },
    /**用来格式化getitemidx变成文字形式 */
    getItemChar(item: number, idx: number, sum: number) {
        return this.getItemidx(item, idx, sum).toString();
    },
    getIcon(name: string) {
        return token.getImg(name);
    },
    getIconByHash(name: string){
        return token.getImgByHash(name);
    },
    openToken(iten: string) {
        window.open("/token/" + iten);
    }
};

/**分页配置 */
const page = {
    max: 3,
    sum: 10
};

const title_nvas = [
    {
        label: "1H",
        value: "H"
    },
    {
        label: "1D",
        value: "D"
    }
];
const tab_key = ref<TabItem>(title_nvas[0]);
const tab2_key = ref<TabItem>(title_nvas[0]);
const tab3_key = ref<TabItem>(title_nvas[1]);
const tab4_key = ref<TabItem>(title_nvas[0]);
const tabKeys = { tab_key, tab2_key, tab3_key, tab4_key };

export { title_nvas, tabKeys, page, commFun, TabType };
export type { ABNORMAL_TOP, UP, DOWN, TURNOVER, Transactions, HOT };

enum TabType {
    Tab,
    TabB,
    TabC,
    TabD
}
interface TabItem {
    label: string;
    value: string;
}

interface ABNORMAL_TOP<DateType> {
    success: boolean;
    data: DateType[];
}
//热度热度榜
interface HOT {
    baseToken: string;
    baseTokenPriceUsd: number;
    baseTokenPriceNativeCurrency: number;
    quoteToken: string;
    quoteTokenPriceUsd: number;
    quoteTokenPriceNativeCurrency: number;
    baseTokenPriceQuoteToken: number;
    quoteTokenPriceBaseToken: number;
    address: string;
    name: string;
    symbol: string;
    poolCreatedAt?: any;
    fdvUsd: number;
    marketCapUsd?: any;
    transactions: Transactions;
    priceChangeH1: number;
    priceChangeH24: number;
    volumeUsdH24: number;
    reserveInUsd: number;
    swapNumH1: number;
    swapNumH24: number;
}

interface Transactions {
    h1: H1;
    h24: H1;
}
interface H1 {
    buys: number;
    sells: number;
}

//涨幅榜
interface UP {
    baseToken: string;
    baseTokenPriceUsd: number;
    baseTokenPriceNativeCurrency: number;
    quoteToken: string;
    quoteTokenPriceUsd: number;
    quoteTokenPriceNativeCurrency: number;
    baseTokenPriceQuoteToken: number;
    quoteTokenPriceBaseToken: number;
    address: string;
    name: string;
    symbol: string;
    poolCreatedAt: string;
    fdvUsd: number;
    marketCapUsd?: any;
    transactions: Transactions;
    priceChangeH1: number;
    priceChangeH24: number;
    volumeUsdH24: number;
    reserveInUsd: number;
    swapNumH1: number;
    swapNumH24: number;
}
//跌幅榜
interface DOWN {
    baseToken: string;
    baseTokenPriceUsd: number;
    baseTokenPriceNativeCurrency: number;
    quoteToken: string;
    quoteTokenPriceUsd: number;
    quoteTokenPriceNativeCurrency: number;
    baseTokenPriceQuoteToken: number;
    quoteTokenPriceBaseToken: number;
    address: string;
    name: string;
    symbol: string;
    poolCreatedAt: string;
    fdvUsd: number;
    marketCapUsd?: any;
    transactions: Transactions;
    priceChangeH1: number;
    priceChangeH24: number;
    volumeUsdH24: number;
    reserveInUsd: number;
    swapNumH1: number;
    swapNumH24: number;
}
//最高交易量
interface TURNOVER {
    baseToken: string;
    baseTokenPriceUsd: number;
    baseTokenPriceNativeCurrency: number;
    quoteToken: string;
    quoteTokenPriceUsd: number;
    quoteTokenPriceNativeCurrency: number;
    baseTokenPriceQuoteToken: number;
    quoteTokenPriceBaseToken: number;
    address: string;
    name: string;
    symbol: string;
    poolCreatedAt?: any;
    fdvUsd: number;
    marketCapUsd?: any;
    transactions: Transactions;
    priceChangeH1: number;
    priceChangeH24: number;
    volumeUsdH24: number;
    reserveInUsd: number;
    swapNumH1: number;
    swapNumH24: number;
}
